
package com.chuanke.ckfamily.service.social;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import com.chuanke.ckfamily.service.common.exception.LockException;
import org.apache.http.ParseException;

import com.chuanke.ckfamily.dao.base.Page;
import com.chuanke.ckfamily.dao.social.model.Family;
import com.chuanke.ckfamily.dao.user.model.User;
import com.chuanke.ckfamily.service.exception.CFException;
import com.chuanke.ckfamily.service.exception.FamilyExcepiton;
import com.weijie.core.IBaseBiz;

public interface FamilyService extends IBaseBiz<Family> {


	void fixFamilyMember();

	void fixFamily(Long fid, Long uid) throws CFException;

	void update(Family family);

	/**
	 * 增加家族成员数量
	 *
	 * @param fid
	 */
	Integer addFmebmer(Long fid, Long caption) throws LockException;

	/**
	 *
	 *
	 * @param fid
	 * @return
	 */
	Integer reduceFmember(Long fid) throws LockException;

	/**
	 *
	 *
	 * @param fid
	 * @return
	 */
	Integer getFmember(Long fid);

	Family getByOwner(Long userId) throws CFException;

	/**
	 * 用户登录分配家族
	 * @param userId
	 * @param excludeFamilyId 加入家族时排除指定家族
	 * @return
	 * @throws CFException 
	 * @throws IOException 
	 * @throws ParseException 
	 */
	boolean addFamilyBylogin(Long userId,Long excludeFamilyId) throws CFException;
	
	/**
	 * @param userId
	 * @return
	 * @throws CFException 
	 */
	public Family findFamilyByUserId(Long userId);

	/**
	 * 每日结算完，刷新家族排行榜
	 * @param time 用户id
	 * @return
	 * @throws CFException 
	 */
	public void refreshRank(String time) throws CFException;
	

	/**
	 * 我的家族
	 * @param userId
	 * @return
	 * @throws CFException 
	 */
	public Map<String, Object> myFamily(Long userId) throws Exception;
	
	/**
	 * 家族信息
	 * @param userId
	 * @param familyId
	 * @param tid 
	 * @return
	 * @throws CFException 
	 */
	public Map<String, Object> familyInfo(Long userId, Long familyId, String tid) throws FamilyExcepiton, CFException;

	/**
	 * 创建家族
	 * @param userId
	 * @param familyName 
	 * @param icon 
	 * @return
	 * @throws CFException 
	 * @throws IOException 
	 * @throws ParseException 
	 */
	public Family createFamily(Long userId, String familyName, String icon) throws CFException,Exception;

	/**
	 * 修改群相关信息
	 * @param uid
	 * @param announcement
	 * @param icon
	 * @param familyName
	 * @param familyName2 
	 * @return
	 * @throws FamilyExcepiton 
	 * @throws CFException 
	 * @throws IOException 
	 * @throws ParseException 
	 */
	public Family familyUpdate(Long uid, String tid,String announcement, String icon, String familyName) throws FamilyExcepiton, CFException, ParseException, IOException;

	/**
	 * 家族成员
	 * @param uid
	 * @param nickName
	 * @param sort
	 * @param order
	 * @param p 
	 * @param date 
	 * @param tid 
	 * @return
	 * @throws java.text.ParseException 
	 * @throws ParseException 
	 * @throws CFException 
	 */
	public Map<String, Object> familyMember(Long uid, String nickName,int sort, Integer order, Long date, Integer p, String tid)throws FamilyExcepiton, ParseException, java.text.ParseException, CFException;
	/**
	 * 家族收益
	 * @param uid
	 * @param tid 
	 * @return
	 * @throws CFException 
	 */
	public Map<String, Object> income(Long uid, String tid)throws FamilyExcepiton, CFException;
	
	/**
	 * 下线家族
	 * @param superId
	 * @return
	 */
	public List<Family> findFamilyBySuperId(Long superId);

	/**
	 * 粉丝家族
	 * @param uid
	 * @param p
	 * @return
	 */
	public Map<String, Object> fansFamily(Long uid, String keyword, Integer p);

	/**
	 * 家族消息面打扰
	 * @param uid
	 * @param nocall
	 * @param tid 
	 * @return
	 * @throws CFException 
	 * @throws IOException 
	 * @throws ParseException 
	 */
	public Map<String, Object>  familyNocall(Long uid, int nocall, String tid) throws CFException, ParseException, IOException;

	 /**
	  * 返回家族公告已读数量
	  * @param uid
	 * @param tid 
	  * @return
	  */
	public int announcement_read(Long uid, String tid)throws CFException;

	/**
	 * 
	 * 三天未活跃的家族成员
	 * @param uid
	 * @param keyword
	 * @param p
	 * @param tid 
	 * @return
	 * @throws CFException 
	 */
	public List<User> getCanDeleteMember(Long uid, String keyword, Integer p, String tid) throws CFException;
	/**
	 * 成员数量，成员退家族提示,领取红包提示
	 * @param uid
	 * @param tid 
	 * @return
	 * @throws CFException
	 * @throws java.text.ParseException 
	 * @throws ParseException 
	 */
	public Map<String, Object> getFamilyNotice(Long uid, String tid) throws CFException, ParseException, java.text.ParseException;
	/**
	 * 忽略退家族提示，领取红包提示
	 * @param uid 
	 * @param type 
	 * @param tid 
	 * @return
	 */
	public boolean ignoreNotice(Long uid, int type, String tid) throws CFException;
	/**
	 * 初始化昨日家族排行
	 */
	public void initRank();

	public Family findByIdForUpdate(Long id);
	
	public List<Long> getAllFamilyId();
}